@rem echo off
if "%1" == "" goto :usage
if /i %1 == all goto :gnu
if /i %1 == gnu goto :gnu
if /i %1 == intel goto :intel
if /i %1 == intel2 goto :intel2
if /i %1 == openmp goto :openmp
if /i %1 == clean goto :clean
if /i %1 == remove goto :remove
goto :eof

:intel2
set WORKING_DIR=%cd%
cd "%VS90COMNTOOLS%..\..\VC\"
call "%VS90COMNTOOLS%..\..\VC\vcvarsall" x86
cd "%IFORT_COMPILER11%Bin\"
call "%IFORT_COMPILER11%Bin\ifortvars.bat" ia32
cd WORKING_DIR
ifort /Ot /G5 /Qparallel /Qpar-report1 darray.f90 sphera_2d.f90 -o sphera_2d_intel2.exe
if /i %2 == replot goto :reploti
goto :eof

:intel
set WORKING_DIR=%cd%
cd "%VS90COMNTOOLS%..\..\VC\"
call "%VS90COMNTOOLS%..\..\VC\vcvarsall" x86
cd "%IFORT_COMPILER11%Bin\"
call "%IFORT_COMPILER11%Bin\ifortvars.bat" ia32
cd WORKING_DIR
ifort /Ot /G7 /Qparallel /Qpar-report1 darray.f90 sphera_2D.f90 -o sphera_2d_intel.exe
if /i %2 == replot goto :reploti
goto :eof

:openmp
set WORKING_DIR=%cd%
cd "%VS90COMNTOOLS%..\..\VC\"
call "%VS90COMNTOOLS%..\..\VC\vcvarsall" x86
cd "%IFORT_COMPILER11%Bin\"
call "%IFORT_COMPILER11%Bin\ifortvars.bat" ia32
cd WORKING_DIR
ifort /F0x10000000 /G7 /Qparallel /Qpar-report1 /Qopenmp /Qopenmp-report1 darray.f90 sphera_2D.f90 -o sphera_2D_openmp.exe
if /i %2 == replot goto :reploti
goto :eof


:reploti
ifclink -c replot darray.obj
goto :eof

:gnu
gfortran -c -g darray.f90
gfortran -c -g sphera_2D.f90
gfortran darray.o sphera_2D.o -o sphera_2D_gnu.exe
if /i %2 == replot goto :replotg
goto :eof

:replotg
gf95link -c replot darray.o
goto :eof

:clean
del *.*~
del *.o
del *.obj
del *.mod
goto :eof

:remove
del *.exe
del *.*~
del *.o
del *.obj
del *.mod
goto :eof

:usage
@echo Options:
@echo intel - compile with intel fortran
@echo gnu - compile with gfortran
@echo clean - remove executable, module and object files 
@echo Good luck!
:eof
